package com.jason.library.common.base

import android.app.Application
import androidx.lifecycle.MutableLiveData

open class BasePageViewModel<T>(application: Application) : BaseViewModel(application) {


    val data = MutableLiveData<DataWrapper<List<T>>>()

    private var curPage: Int = 1

    fun loadData() {
        curPage = 1
        if(isFirstPage()) {
            showLoading()
        }
        loadData(curPage)
    }

    fun loadMoreData() {
        curPage++
        loadData(curPage)
    }

    fun isFirstPage() = curPage == 1

    open fun loadData(page: Int) {

    }

}